home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15319 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  57 lines

  1. Path: news.bs.tpl.net!news
  2. From: Dieter Lⁿcking <luecking@braunschweig.netsurf.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Help:ostrstream,strstreambuf
  5. Date: Thu, 04 Apr 1996 20:47:57 +0100
  6. Organization: IRD Daten- und Netzwerktechnik
  7. Message-ID: <3164276D.5FD0@braunschweig.netsurf.de>
  8. NNTP-Posting-Host: plueckin.braunschweig.netsurf.de
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (Win95; I)
  13.  
  14. I attempt to implement a stream for message boxes.
  15. First the example:
  16.  
  17.    class MessageBuffer : public strstreambuf
  18.    {
  19.       public:
  20.       MessageBuffer()
  21.       : strstreambuf()
  22.       {}
  23.       
  24.       // ... more constructors
  25.       
  26.       virtual int sync()                   // *** First question *** //
  27.       {
  28.          // Target specific implementation.
  29.          // A simple example:
  30.          cout << this; return __NOT_EOF;
  31.       }
  32.    };
  33.    
  34.    class Message : public ostrstream
  35.    {
  36.       public:
  37.       Message()
  38.       : ostrstream()
  39.       { init(new MessageBuffer); }          // *** Second question *** 
  40. //
  41.       
  42.       // ... more constructors
  43.    };
  44.  
  45. First question:
  46. The function sync() should only executed if ostream::flush() is called. 
  47. However
  48. i am not sure. Are there any side effects ?
  49.  
  50. Second question:
  51. Deletes ~ios() any the streambuffer object or is it a job for ~Message() 
  52. ?
  53.  
  54. Thanks
  55.    Dieter Luecking
  56.  
  57.